/*
    backend for TimeTagger, an OpalKelly based single photon counting library
    Copyright (C) 2011  Markus Wick <wickmarkus@web.de>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef BACKEND_COUNTER_H_
#define BACKEND_COUNTER_H_

#include <string>
#include "TimeTagger.h"

class Counter : public _Iterator {
public:
	Counter(int _chan, long long _binwidth, int _bins = 1);
	virtual ~Counter();

	virtual const char * getScpiCommand();
	virtual std::string getScpiParameters();
	virtual const char *getClassName();
	virtual void getMeta(long long **ARGOUTVIEWM_ARRAY2, int *DIM1);

	virtual void clear();
	void getData(int **ARGOUTVIEWM_ARRAY1, int *DIM1);

	virtual void next(Tag* list, int count, long long time);

private:
	int *data;

	int chan;
	long long binwidth;
	int bins;

	int pos;
	long long starttime;
};

class Countrate : public _Iterator {
public:
	Countrate(int _chan);
	virtual ~Countrate();

	virtual const char *getClassName();
	virtual const char * getScpiCommand();
	virtual std::string getScpiParameters();
	virtual void getMeta(long long **ARGOUTVIEWM_ARRAY2, int *DIM1);

	double getData();
	virtual void clear();

protected:
	virtual void next(Tag* list, int count, long long time);

private:
	int chan;

	long long now;
	long long startzeit;
	long long flanken;
};

#endif /* COUNTER_H_ */
